package org.example.flinksql.test.custom;

import org.apache.flink.table.functions.ScalarFunction;
import org.example.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TransEntityTypeFunc extends ScalarFunction {
    private final Logger logger = LoggerFactory.getLogger(TransEntityTypeFunc.class);

    public Integer eval(String str) {
        try {
            Integer integer = Utils.str2Integer(str);
            if (null == integer) {
                return 0;
            } else {
                return integer;
            }
        } catch (Exception e) {
            logger.warn(String.format("%s :: %s :: [%s]", e.getMessage(), e.getCause(), str));
            return null;
        }
    }
}
